<?php
/**
 * Plotter per il grafico "ZoneSensibleHeatingEnergy"
 */
Zend_Loader::loadClass("Application_Plotter_Base");
Zend_Loader::loadClass("Application_PlotData");
Zend_Loader::loadClass('Output_Time');
Zend_Loader::loadClass('Output_ReportVariableData');
Zend_Loader::loadClass('Output_ReportVariableDataDictionary');

class ZoneSensibleHeatingEnergy extends Application_Plotter_Base
{
	public function call() {
		
		$stmt = $this->_db->query('
			SELECT Month, Day, Hour, Minute, VariableValue
			FROM ReportVariableData
			INNER JOIN ReportVariableDataDictionary ON ReportVariableData.ReportVariableDataDictionaryIndex=ReportVariableDataDictionary.ReportVariableDataDictionaryIndex
			INNER JOIN Time ON ReportVariableData.TimeIndex = Time.TimeIndex
			WHERE ReportVariableDataDictionary.VariableName = ?
		', array ("Zone/Sys Sensible Heating Energy"));
		$results = $stmt->fetchAll($query);
		//Zend_Debug::dump($results);
		
		if (!empty($results)) {
			foreach ($results as &$result) {
				$dataPoints[] = (float) $result['VariableValue'] * 0.000001;
				$x[] = sprintf ("%01d/%02d", $result['Day'], $result['Month']); 
			}
			$plotData = new Application_PlotData("Zone Sensible Heating Energy");
			$plotData->setXAxis($x, "s", "Ascissa", "Tempo di Simulazione");
			$plotData->setYAxis(null, "MJ", "Ordinate", "Energia");
			$plotData->addSerie($dataPoints, "MJ", "Serie 1", "Sensible Heating Energy");
			$plotData->useCartridge('scale-from-0');
			return $plotData;
		}

		/*
		$rvdd = new Output_ReportVariableDataDictionary();
		$dataDict = $rvdd->select()->where("VariableName = ?", "Zone/Sys Sensible Cooling Energy");
		$result = $rvdd->fetchAll($dataDict);
		*/
		
	}
}
